import torch


def move_to(obj, device):
    if torch.is_tensor(obj):
        return obj.to(device)
    elif isinstance(obj, dict):
        return {
            k: move_to(v, device)
            for k, v in obj.items()
        }
    elif isinstance(obj, list):
        return [
            move_to(v, device)
            for v in obj
        ]
    elif isinstance(obj, tuple):
        return tuple(
            move_to(v, device)
            for v in obj
        )
    else:
        return obj
